﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license
 
 This code is provided on an AS IS basis, with no WARRANTIES,
  CONDITIONS or GUARANTEES of any kind.
-->
<UserControl x:Class="Peter.View.ViewEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:logic="clr-namespace:Peter.Logic"
             xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             xmlns:autoComplete="clr-namespace:Peter.Common.AutoComplete;assembly=Peter.Common"
             xmlns:common="clr-namespace:Peter.Common;assembly=Peter.Common"
             mc:Ignorable="d"
             d:DesignHeight="500"
             d:DesignWidth="800"
             d:DataContext="{d:DesignInstance logic:ModelEditor}">
   <Grid FocusManager.FocusedElement="{Binding ElementName=EditorContentControl}">
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
         <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>

      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="*" />
         <ColumnDefinition Width="Auto" />
      </Grid.ColumnDefinitions>
      
      <Grid Grid.Row="0"
            Grid.Column="0"
            Grid.ColumnSpan="2"
            x:Name="GotoBar"
            Margin="5,0"
            Visibility="{Binding Path=IsGotoLineVisible, Converter={StaticResource _BoolToVisi}}">

         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
         </Grid.ColumnDefinitions>
         
         <TextBlock Grid.Column="0"
                    Text="Go to line #"
                    VerticalAlignment="Center"/>
         <TextBox Grid.Column="1"
                  Width="75"
                  Margin="4,0"
                  TextAlignment="Right"
                  x:Name="GotoTextBox"
                  Text="{Binding Path=GotoLineNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                  KeyDown="OnGotoLineKeyDown"/>
         <Button Grid.Column="2"
                 Click="OnGotoLineClick">
            <icons:IconDisplay IconSize="Small"
                               Icon="CircleArrowRight"
                               Margin="3,0"/>
         </Button>
      </Grid>

      <ContentControl Grid.Row="1"
                      Grid.Column="0"
                      x:Name="EditorContentControl"
                      Content="{Binding Path=Editor}" />

      <Grid Grid.Row="2"
            Grid.Column="0"
            Grid.ColumnSpan="2"
            x:Name="FindBar"
            Margin="0,2,0,0"
            Visibility="{Binding Path=IsFindBarVisible, Converter={StaticResource _BoolToVisi}}">

         <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
         </Grid.RowDefinitions>

         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
         </Grid.ColumnDefinitions>

         <Button Grid.Column="0"
                 Grid.Row="0"
                 Click="OnFindReplaceToggle"
                 ToolTip="Toggles between find and replace mode">
            <icons:IconDisplay Icon="Search"
                               FontSize="10"
                               Margin="2,0"
                               x:Name="IconFindReplaceToggle" />
         </Button>

         <controls:CommandTextBox Grid.Column="1"
                                  Grid.Row="0"
                                  Width="200"
                                  FontSize="10"
                                  x:Name="FindTextBox"
                                  Command="{x:Static common:PeterApplicationCommands.FindNext}"
                                  autoComplete:AutoComplete.DataProvider="{Binding Path=SearchAutoComplete}"
                                  Text="{Binding Path=FindText, UpdateSourceTrigger=PropertyChanged}"
                                  PreviewKeyDown="OnSearchKeyDown"
                                  TextWrapping="NoWrap"
                                  VerticalAlignment="Center"
                                  VerticalContentAlignment="Center" />

         <controls:CommandTextBox Grid.Column="1"
                                  Grid.Row="1"
                                  Width="200"
                                  FontSize="10"
                                  x:Name="ReplaceTextBox"
                                  Visibility="Collapsed"
                                  autoComplete:AutoComplete.DataProvider="{Binding Path=SearchAutoComplete}"
                                  Text="{Binding Path=ReplaceText, UpdateSourceTrigger=PropertyChanged}"
                                  PreviewKeyDown="OnSearchKeyDown"
                                  TextWrapping="NoWrap"
                                  VerticalAlignment="Center"
                                  VerticalContentAlignment="Center" />

         <Button Grid.Column="2"
                 Grid.Row="0"
                 Margin="4,0"
                 ToolTip="Find Next (F3)"
                 FontSize="10"
                 Width="75"
                 Command="{x:Static common:PeterApplicationCommands.FindNext}">
            <StackPanel Orientation="Horizontal">
               <icons:IconDisplay Icon="Next"
                                  FontSize="10"
                                  Margin="2,0" />
               <TextBlock Text="Next"
                          Margin="2,0" />
            </StackPanel>
         </Button>

         <Button Grid.Column="3"
                 Grid.Row="0"
                 ToolTip="Find Previous (Shift+F3)"
                 FontSize="10"
                 Width="75"
                 Command="{x:Static common:PeterApplicationCommands.FindPrevious}">
            <StackPanel Orientation="Horizontal">
               <icons:IconDisplay Icon="Previous"
                                  FontSize="10"
                                  Margin="2,0" />
               <TextBlock Text="Previous"
                          Margin="2,0" />
            </StackPanel>
         </Button>

         <Button Grid.Column="2"
                 Grid.Row="1"
                 FontSize="10"
                 Width="75"
                 Visibility="Collapsed"
                 x:Name="_BtnReplaceNext"
                 Command="{x:Static common:PeterApplicationCommands.Replace}">
            <StackPanel Orientation="Horizontal">
               <icons:IconDisplay Icon="Next"
                                  FontSize="10"
                                  Margin="2,0" />
               <TextBlock Text="Replace"
                          Margin="2,0" />
            </StackPanel>
         </Button>

         <Button Grid.Column="3"
                 Grid.Row="1"
                 FontSize="10"
                 Width="75"
                 Visibility="Collapsed"
                 x:Name="_BtnReplaceAll"
                 Command="{x:Static common:PeterApplicationCommands.ReplaceAll}">
            <StackPanel Orientation="Horizontal">
               <icons:IconDisplay Icon="Refreshalt"
                                  FontSize="10"
                                  Margin="2,0" />
               <TextBlock Text="Replace All"
                          Margin="2,0" />
            </StackPanel>
         </Button>

         <CheckBox Grid.Column="4"
                   Margin="4,0"
                   Grid.Row="0"
                   IsChecked="{Binding Path=FindCaseSensitive}"
                   HorizontalAlignment="Center"
                   HorizontalContentAlignment="Center"
                   VerticalAlignment="Center"
                   VerticalContentAlignment="Center"
                   FontSize="10"
                   Content="Case Sensitive" />

         <TextBlock Grid.Column="6"
                    Grid.Row="0"
                    Margin="4,0"
                    VerticalAlignment="Center"
                    FontSize="10"
                    Text="{Binding Path=FindOccurrences}" />

         <Button Grid.Column="7"
                 Grid.Row="0"
                 ToolTip="Hide Search"
                 Click="OnHideSearch">
            <icons:IconDisplay Icon="ChevronDown"
                               FontSize="10"
                               Margin="2,0" />
         </Button>
      </Grid>
   </Grid>
</UserControl>